﻿using Elsa.Http;
using Elsa.Workflows.Activities;
using Microsoft.AspNetCore.Mvc;
using Elsa.Workflows.Contracts;

namespace ElsaController.Controllers
{
    [Route("api/[controller/[action]]")]
    [ApiController]
    public class RunWorkflowController : ControllerBase
    {
        private IWorkflowRunner _workflowRunner;

        public RunWorkflowController(IWorkflowRunner workflowRunner)
        {
            _workflowRunner = workflowRunner;
        }

        [HttpGet]
        public async Task GetElsa()
        {
            Sequence sequence = new Sequence
            {
                Activities = {
                   new WriteLine("工作流步骤1")
                 , new WriteLine("工作流步骤2")
                 , new WriteLine("工作流步骤3")
                 , new WriteLine("工作流步骤4")
                 , new WriteLine("工作流步骤5")
                 , new WriteHttpResponse()
                    {
                        Content=new("hellw world or http workflows")
                    }
                }
            };
            await _workflowRunner.RunAsync(sequence);
        }
    }
}